home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib-tk / ScrolledText.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-11-11  |  2.5 KB  |  58 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''A ScrolledText widget feels like a text widget but also has a
  5. vertical scroll bar on its right.  (Later, options may be added to
  6. add a horizontal bar as well, to make the bars disappear
  7. automatically when not needed, to move them to the other side of the
  8. window, etc.)
  9.  
  10. Configuration options are passed to the Text widget.
  11. A Frame widget is inserted between the master and the text, to hold
  12. the Scrollbar widget.
  13. Most methods calls are inherited from the Text widget; Pack, Grid and
  14. Place methods are redirected to the Frame widget however.
  15. '''
  16. __all__ = [
  17.     'ScrolledText']
  18. from Tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
  19. from Tkconstants import RIGHT, LEFT, Y, BOTH
  20.  
  21. class ScrolledText(Text):
  22.     
  23.     def __init__(self, master = None, **kw):
  24.         self.frame = Frame(master)
  25.         self.vbar = Scrollbar(self.frame)
  26.         self.vbar.pack(side = RIGHT, fill = Y)
  27.         kw.update({
  28.             'yscrollcommand': self.vbar.set })
  29.         Text.__init__(self, self.frame, **kw)
  30.         self.pack(side = LEFT, fill = BOTH, expand = True)
  31.         self.vbar['command'] = self.yview
  32.         methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()
  33.         for m in methods:
  34.             if m[0] != '_' and m != 'config' and m != 'configure':
  35.                 setattr(self, m, getattr(self.frame, m))
  36.                 continue
  37.         
  38.  
  39.     
  40.     def __str__(self):
  41.         return str(self.frame)
  42.  
  43.  
  44.  
  45. def example():
  46.     import __main__
  47.     END = END
  48.     import Tkconstants
  49.     stext = ScrolledText(bg = 'white', height = 10)
  50.     stext.insert(END, __main__.__doc__)
  51.     stext.pack(fill = BOTH, side = LEFT, expand = True)
  52.     stext.focus_set()
  53.     stext.mainloop()
  54.  
  55. if __name__ == '__main__':
  56.     example()
  57.  
  58.